home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1070 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: frigault@gla.ecoledoc.ibp.fr (Laurent FRIGAULT)
  3. Newsgroups: comp.std.c++,comp.lang.c++.moderated
  4. Subject: references and ellipsis
  5. Date: 13 Apr 1996 23:17:34 GMT
  6. Organization: Universites Paris VI/Paris VII - France
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4kop8j$ino@vishnu.jussieu.fr>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Nntp-Posting-Host: daisy-gtw.ecoledoc.ibp.fr
  14. X-Newsreader: knews 0.9.5
  15. Content-Length: 943
  16. Originator: clamage@taumet
  17.  
  18. Hi,
  19.  
  20. I discover a problem when trying to use a C++ reference to an object
  21. just before an ellipsis :
  22.  
  23. int foo(const int& aInt,...){
  24. va_list params;
  25.  
  26.     va_start(params,aInt);
  27.     // ...
  28.     va_end(params);
  29.  
  30.     return 0;
  31.  
  32. }
  33.  
  34. I try this kind of code under several environnement and it compile well.
  35. g++ 2.7.2 under sunos 4.1.3 give me a warning:
  36. warning: second parameter of `va_start' not last named argument
  37. but the code works fine.
  38.  
  39. Under NT with BC++ 4.51 and VC++ 2.1, I dont get any warning, but
  40. the generated code is wrong.
  41.  
  42. If I replace the reference with a pointer or an object, the code works
  43. in all cases. I couldn't find anything about a reference before an ellipsis
  44. on the draft, so I presume that the code is correct.
  45. Can someone confirm if this is correct or not.
  46.  
  47. If yes, I presume that the problem is in the implementation of va_start
  48. that uses sizeof on the reference.
  49.  
  50. regards
  51.  
  52. Lolo
  53. --
  54.   Laurent Frigault | frigault@gla.ecoledoc.ibp.fr
  55.  
  56.  
  57.  
  58. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  59. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  60. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  61. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  62. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  63.